package com.guoxiang.bigdata.util;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.io.IOException;
import java.util.Properties;

public class JedisUtil {
    private JedisUtil() {
    }

    private static final Properties prop;

    /**
     *静态代码块只执行一次
     */
    static {
        prop = new Properties();
        try {
            prop.load(JedisPool.class.getClassLoader().getResourceAsStream("redis.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static Jedis getConn() {
        return new Jedis((String) prop.get("host"), Integer.valueOf(prop.get("port").toString()));
    }}
